#ifndef _CORE_SEARCHTREE_H_
#define _CORE_SEARCHTREE_H_

#define SEARCHTREE_MAXSPAN	40

#define SEARCHTREE_NODEADDED	1
#define SEARCHTREE_NODEREPLACED	2
#define SEARCHTREE_NODEDELETED	3
#define SEARCHTREE_NODENOTFOUND	4

typedef void (*TSearchTreeCallbackDelete)(void *data);
class CSearchTree
{
private:
	typedef struct __treeItem
	{
		__treeItem *parent;
		__treeItem *items[SEARCHTREE_MAXSPAN];
		char c;
		void* data;
	}TTreeItem;

	TTreeItem *m_root;

	TSearchTreeCallbackDelete m_delCallback;

	TTreeItem *createNode(TTreeItem *parent);
	int getCharPos(char c);

	void deleteChildren(TTreeItem *item);
	void deleteData(TTreeItem *item);

public:
	CSearchTree();
	~CSearchTree();

	int addNode(const char *name, void* data);
	void* getNode(const char *name);
	int deleteNode(const char *name);

	TSearchTreeCallbackDelete registerDeleteCallback(TSearchTreeCallbackDelete delCallback);
};

#endif //_CORE_SEARCHTREE_H_